<?php
require_once BaseUtil::getModulePath("base")  .  '/services/BaseService.php';
require_once BaseUtil::getModulePath("trade")  .  '/models/AccountAgentTotalDao.php';
require_once BaseUtil::getModulePath("trade")  .  '/models/AccountAgentTradeLogDao.php';
require_once BaseUtil::getModulePath("trade")  .  '/models/AgentDao.php';
require_once BaseUtil::getModulePath("customer")  .  '/models/CustomerDao.php';
require_once BaseUtil::getModulePath("component") . '/Number.php';

class SupplementService extends BaseService {
	private $agentDao;
	private $accountAgentTradeLogDao;
	private $accountAgentTotalDao;
	private $customerDao;

	public function __construct(){
		parent::__construct();

		$this->agentDao = new AgentDao();
		$this->agentDao->setDb($this->db);

		$this->accountAgentTotalDao = new AccountAgentTotalDao();
		$this->accountAgentTotalDao->setDb($this->db);

		$this->accountAgentTradeLogDao = new AccountAgentTradeLogDao();
		$this->accountAgentTradeLogDao->setDb($this->db);
		
        $this->customerDao = new CustomerDao();
        $this->customerDao->setDb($this->db);    		
	}

	public function getAccountAgentTotalsByUserId($id){//david
		return $this->accountAgentTotalDao->getInfoByUserId($id);
	}

	public function updateAccountAgentTotalsByUserId($data, $id){//david
		return $this->accountAgentTotalDao->updateAccountAgentTotalsByUserId($data, $id);
	}

	public function updateAccountAgentTradeLogById($data, $id){//david
		return $this->accountAgentTradeLogDao->updateLastTradeLog($data, $id);
	}

	public function insertAccountAgentTradeLog($data){//david
		return $this->accountAgentTradeLogDao->insertTradeLog($data);
	}

	public function getSupplementById($id){//david
		return $this->accountAgentTradeLogDao->getTradeLogById($id);
	}

	public function updateSupplementById($set, $id){
		$this->accountAgentTradeLogDao->updateSupplementById($set, $id);
	}

	public function deleteSupplement($id){
		$this->accountAgentTradeLogDao->deleteTradeLog($id);
	}

	public function getSupplementtradeTotalSum($trade_type, $status, $date1, $date2){
		return $this->accountAgentTradeLogDao->getSupplementtradeTotalSum($trade_type, $status, $date1, $date2);
	}
	
	public function getUserByName($name){
		 $user = $this->customerDao->getCustomerByName($name);
         return $user['id'];
	}
}
?>